import { selectClassPlanItem , selectClassPlanInitItem , viewSortItem} from '@/utils/viewPlan';
import { ProjectViewPlanViewItem } from "@/utils/students/viewPlanItem";
import { makeAutoObservable } from 'mobx';
import { GetclassRank , GetselectClassPlanInit , classRankSort , GetViewValueItem } from '@/services/index';

class selectClassPlan {
    constructor() {
        makeAutoObservable(this);
    }

    DetailValue : selectClassPlanItem = {} as selectClassPlanItem;

    DetailItem : selectClassPlanInitItem = {} as selectClassPlanInitItem;

    DitailSort : viewSortItem[] = [] as viewSortItem[];

    ViewValue:ProjectViewPlanViewItem = {} as ProjectViewPlanViewItem;

    async GetGetclassRankValue( params : string){
        let result = await GetclassRank(params);
        
        if( result.data )
        {
            this.DetailValue = result.data;
        }
    }

    // 获取列表
    async GetselectClassPlanInit( params : string){
        let result = await GetselectClassPlanInit(params);
        
        if( result.data )
        {
            this.DetailItem = result.data;
        }
    }

    // 获取排行
    async GetclassRankSort( params : string ){
        let result = await classRankSort(params);

        // 简单的容错处理
        if( result.data )
        {
          this.DitailSort = result.data
        }
    }
    

    async GetViewValue(){
        let result = await GetViewValueItem();
        this.ViewValue = result.data;
        console.log(result.data);
        
    }
}

export default new selectClassPlan;